<template>
  <a-result :status="status" :title="status" :sub-title="subTitle">
    <template #extra>
      <a-button type="primary" @click="$router.push('/')">返回首页</a-button>
    </template>
  </a-result>
</template>

<script>
const codeMap = {
  404: '对不起，您访问的页面不存在',
  error: '发生一些未知的错误，请联系管理员'
}

export default {
  name: 'UnknowError',
  data() {
    return {
      status: '404'
    }
  },
  computed: {
    title() {
      return this.status
    },
    subTitle() {
      return codeMap[this.status]
    }
  },
  created() {
    const status = this.$route.params.status || '404'
    this.status = this.getStatus(status)
  },
  methods: {
    getStatus(status) {
      if (!['success', 'error', 'info', 'warning', '404', '403', '500'].includes(status)) {
        status = '404'
      }
      return status
    }
  }
}
</script>
